#ifndef SPRING_H
#define SPRING_H

#include "color.h"
#include "particle.h"
#include "matrix.h"

#define STRUCTURAL_HORIZONTAL 0
#define STRUCTURAL_VERTICAL 1
#define SHEAR 2
#define FLEXION 3

class Spring
{
	public:

		Spring();

		Spring(int, unsigned int, int, int);

		Spring(int, unsigned int, Particle *, Particle *, const Color &);

		Spring(int, unsigned int, double, double, Particle *, Particle *, const Color &);

		~Spring();

        int getID() const; //return the id of spring

		bool isSelected() const {return selected;};

		void select(bool _b) {selected = _b;};

        unsigned int getType() const; //return the type of spring

		Color getColor() const; //color of spring

		const Color &getActualColor() const; //color of spring

		void setColor(const Color &); //change the color of spring

		void setKsAndKd(double, double); //change both coefficients

		double getKs() const; //returns the coefficient of rigidity

		void setKs(double); //change the coefficient of rigidity

		double getKd() const; //returns the coefficient of damping

		void setKd(double); //change the coefficient of damping

		int getParticleBegin() const; //return the initial particle

		int getParticleEnd() const; //return the end particle

		double getOriginalLength() const; //resting length

		double getCurrentLength(Particle *, Particle *); //calculating the current lenght

		double getCurrentLength(Vector3D , Vector3D); //calculating the current lenght

		bool positiveDelta() const; //said spring is stretched or compressed

		void printK_() const; //return local matrix of stiffness

		void printC_() const; //return local matrix damping

		const Matrix& getK_() const; //return the local matrix of stiffness of the spring

		const Matrix& getC_() const; //return local matrix of damping of the spring

 		void addParticleMass(Particle *, Particle *);//updating the particle's mass

	    void relax(); //relaxed length of the spring

	private:

        int id;

        bool selected;

        unsigned int type; //type of the spring

        Color color;

		int particleBegin; //initial particle

		int particleEnd; //end particle

		double ks; //coefficient stiffness

		double kd; //damping coefficient

		double lo; //resting length of the spring

		double lc; //current length of the spring

        static Matrix k_; //local matrix of stiffness of the spring

        static Matrix c_; //local matrix of damping of the spring

};

#endif
